#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL x, k, d;

int main(){
    cin>>x>>k>>d;
    x = abs(x);
    LL o = x / d;
    if(k >= o){
        k -= o;
        if(k & 1) cout<<abs(x - o * d - d)<<endl;
        else cout<<(x - o * d)<<endl;
    }
    else {
        cout<<x - k * d<<endl;
    }
    
    return 0;
}